import Mock from 'mockjs'

function getWorkOrderList() {
    const json = { code: 200, success: true, msg: '操作成功' };
    const list = [];
    list.push(
        {
            id: '1',
            workOrderNo: '20220329',
            partNo: '2022-03-29',
            partName: '物料一',
            partSpecifications: '001',
            quantity: 10,
            routeJson: true,
            isRoute: true,
            customerOrderNo: 'customerOrderNo1'
        },
        {
            id: '2',
            workOrderNo: '20220330',
            partNo: '2022-03-30',
            partName: '物料一',
            partSpecifications: '002',
            quantity: 100,
            routeJson: false,
            isRoute: false,
            customerOrderNo: 'customerOrderNo2'
        }
    );
    json.data = {
        total: 10,
        size: 10,
        current: 1,
        searchCount: true,
        pages: 1,
        records: list,
    };
    return json;
}

function getWorkOrderDetailList() {
    const json = { code: 200, success: true, msg: '操作成功' };
    const list = [];
    list.push(
        {
            id: 1,
            startSerialNo: 'Alin0228;HOHO1;0001',
            endSerialNo: 'Alin0228;HOHO1;0010',
            quantity: '10',
            printStatus: 'NOT_PRINT',
            createdDate: '2022-02-28 10:22:04',
            typeSource: 'NORMAL'
        },
        {
            id: '2',
            startSerialNo: 'Alin0228;HOHO1;0011',
            endSerialNo: 'Alin0228;HOHO1;0020',
            quantity: '10',
            printStatus: 'NOT_PRINT',
            createdDate: '2022-02-28 10:50:03',
            typeSource: 'NORMAL'
        }
    );
    json.data = {
        total: 10,
        size: 10,
        current: 1,
        searchCount: true,
        pages: 1,
        records: list,
    };
    return json;
}

function getSerialnoList() {
    const json = { code: 200, success: true, msg: '操作成功' };
    const list = [];
    list.push(
        {
            id: '1',
            name: '检验批号(勿删除)',
            code: 'IQCLOTNO',
            sequenceNo: '02018',
            hexString: '0123456789',
            startSequenceNo: '00001',
            prefixed: '',
            suffix: '',
            sequenceNoFormat: '[P][YYYY][M][D][S]',
            yearCode: '22',
            monthCode: '03',
            weekCode: '12',
            dayCode: '18',
            regressionType: 'MONTH',
            incrementQty: 1
        },
        {
            id: '2',
            name: '20211028',
            code: 'oncemore',
            sequenceNo: '28001',
            hexString: '0123456789',
            startSequenceNo: '28001',
            prefixed: 'Y',
            suffix: 'D',
            sequenceNoFormat: '[YY][M][D][S]',
            yearCode: '2021',
            monthCode: '10',
            weekCode: '44',
            dayCode: '28',
            regressionType: 'NEVER',
            incrementQty: 1
        }
    );
    json.data = {
        total: 10,
        size: 10,
        current: 1,
        searchCount: true,
        pages: 1,
        records: list,
    };
    return json;
}

export default ({ mock }) => {
    if (!mock) return;
    Mock.mock(/\/api\/production\/peorder-manage\/list/, 'get', getWorkOrderList);
    Mock.mock(/\/api\/production\/peorder-manage\/detail/, 'get', getWorkOrderDetailList);
    Mock.mock(/\/api\/baseconfig\/sequence-manage\/list/, 'get', getSerialnoList);
}
